package service_logger

import (
	"elflog/common/context"
	"elflog/common/dig"
	"elflog/component/cron"
	"elflog/component/nlog"
	"elflog/module/module-account/service"
	service2 "elflog/module/module-log/service"
)

type LoggerService struct {
	moduleAccount *service.ModuleAccountService
	moduleLog     *service2.ModuleLogService
	cronJobSvc    *cron.NCron // 定时任务
	log           *nlog.NLog
}

func NewLoggerService(log *nlog.NLog, cronSvc *cron.NCron, moduleAccount *service.ModuleAccountService, moduleLog *service2.ModuleLogService) *LoggerService {
	var logSvc = &LoggerService{
		moduleAccount: moduleAccount,
		moduleLog:     moduleLog,
		cronJobSvc:    cronSvc,
		log:           log,
	}
	logSvc.StartCronJob(context.NewContext())
	return logSvc
}

func init() {
	dig.Container.MustProvide(NewLoggerService)
}
